<?php require_once 'source.php';?>
<?php require_once 'config.php';?>
<?php require_once 'dao/dao_db.php';?>
<?php require_once 'dao/dao_teacher_manage.php';?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
 "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title><?php echo SYSTITLE?></title>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
<link rel="stylesheet" type="text/css" href="css/style.css" />
</head>
<body>
<div class="wrapper">
<?php require_once 'header.php';?>
<div id="layout">
	<div id="leftlay"><?php require_once 'leftnav.php';?></div>
	<div id="rightlay">
		<div class="columntitle"><?php echo TEACHERMANAGE?></div>
		<div class="columncontent">
			<div id="students">
			<div><a href="create_account.php"><?php echo CREATETEACHERACCOUNT?></a></div>
			<div style="color:#ff0000;">
				<?php 
					if(isset($_GET['msgcode'])){
						$msgcode=$_GET['msgcode'];
					}else{
						$msgcode='';
					}
					if($msgcode!=''&&$msgcode==1){
						echo SAVESUCCESSFUL;
					}else if($msgcode!=''&&$msgcode==0){
						echo SAVEFAILED;
					}else if($msgcode!=''&&$msgcode==2){
						echo SAVEPASSFAILED;
					}
				?>
			</div>
			<?php 
				if($_SESSION['level']==ADMINISTRATOR){
			?>			
				<table>
					<tr>
						<th><?php echo USERNAME?></th>
						<th><?php echo TEACHERID?></th>
						<th><?php echo GENDER?></th>
						<th><?php echo ACTION?></th>
					</tr>
					<?php
						if($_SESSION['userid']!=''){
							$result=get_teacher_list();
							mysql_close();					
							if(mysql_num_rows($result)!=0){
								while(($row=mysql_fetch_array($result))!=false){							
					?>
					<tr>
						<td><?php echo $row['USERNAME']?></td>
						<td><?php echo $row['USERID']?></td>
						<td>
							<?php 
								if($row['GENDER']==LADY_NUM) echo LADY;
								elseif($row['GENDER']==GENTLEMAN_NUM) echo GENTLEMAN;
							?>
						</td>
						<td>
						<a href="create_account.php?userid=<?php echo $row['USERID']?>&method=modify"><?php echo MODIFY?></a>
						|
						<a href="service/service_teacher_manage.php?userid=<?php echo $row['USERID']?>"  onclick="return confirm('<?php echo CONFIRMDELETEUSER?>')"><?php echo DEL?></a>
						</td>
					</tr>
					<?php 
								}
							}else{
								echo "<td colspan='4'>".DATANULL."</td>";
							}
						}
					?>
				</table>
			<?php 
				}else{
					header("LOCATION:login.php");
				}			
			?>			
			</div>
		</div>
	</div>
</div>
</div>
</body>
</html>
